package se137.hrbust.hlgshopping137.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import se137.hrbust.hlgshopping137.interceptor.AuthInterceptor;

@Configuration
public class WebConfig137 implements WebMvcConfigurer {
        @Autowired
        private AuthInterceptor authInterceptor;

        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(authInterceptor)
                    //.addPathPatterns("/api/**")
                    .excludePathPatterns("/api/auth/login", "/api/auth/register","/hello");
        }

        @Bean
        public BCryptPasswordEncoder bCryptPasswordEncoder() {
            return new BCryptPasswordEncoder();
        }
    }

